package com.azzcs.codeservice.service.impl;

import com.azzcs.codeservice.service.MessageService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.stream.annotation.EnableBinding;
import org.springframework.cloud.stream.messaging.Source;
import org.springframework.messaging.support.MessageBuilder;

/**
 * @Author: wzg
 * @Date: 2021/2/24 上午11:54
 */
@Slf4j
@EnableBinding(Source.class)
public class MessageServiceImpl implements MessageService {

    @Autowired
    private Source source;

    @Override
    public void sendMessage(String message) {
        log.info("send message:"+message);
        source.output().send(MessageBuilder.withPayload(message).build());
    }
}
